package main.service;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import main.entity.ThreadsVO;
import main.entity.UserVO;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service("userService")
public class UserService extends BaseService<UserVO> {

	@Autowired
	private ThreadsService threadsService;
	
	public Boolean hasUser(UserVO userVO){
		Boolean isLogin = false;
		List<UserVO> vo = getBaseDAO().getByEntity(userVO);
		if (vo.size()==1) {
			isLogin=true;
		}
		return isLogin;
	}
	
	public Map<String, Object> userCenter(Integer uID){
		Map<String, Object> infos = new HashMap<String, Object>();
//		List<Object>userinfos = new ArrayList<Object>();
		List<ThreadsVO> threadsVOs = threadsService.getByUID(uID);//display all my threads
		UserVO userVO = getBaseDAO().getByID(UserVO.class, uID);
//		userVO.setPassword("******");//protect password
//		userinfos.add(threadsVOs);
//		userinfos.add(userVO);
		infos.put("threads", threadsVOs);
		infos.put("user", userVO);
		return infos;
	}
	
}
